<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml"  id="teacherForm">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>课表管理</title>
<script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";

    $(function (){
    
    	$("#date").ligerDateEditor();
    	
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        //如果是修改视图,主键不可编辑
        if(viewType=="modify"){
        	 $("#ttid").attr("readonly", "readonly").removeAttr("validate");
        }
        
        //如果是详细试图,所有字段不可编辑
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);

    });
   
    function save(){
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + data.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("gradeList");
                });
            }
        });
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
 </script>
</head>
<body>
	<form name="mainform" method="post"  id="mainform" action="${ctx }/qso/ttableh/save">
        <input type="hidden" name="viewType" value="${viewType}"/>
        <input type="hidden" name="id" value="${command.id}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 90%; margin-top:10px; margin-left:15px;">
        	 <tr>
                <td align="right" class="l-table-edit-td" style="width:15%">课表代码:</td>
                <td align="left" class="l-table-edit-td" style="width:35%">
                	${command.id}
                	<input name="ttid" type="hidden" id="gradeId" value="${command.id}" ltype="text" />
                </td>
                <td align="right" class="l-table-edit-td" style="width:15%">开课老师:</td>
                <td align="left" class="l-table-edit-td" style="width:35%">
					<select style="width: 180px" name="userid" id="userid" ltype="select" >
                	 	<c:forEach items="${userids}" var="varId">
                	 		<c:choose>
                	 			<c:when test="${command.userid eq  varId.empId}">
                	 				<option value="${varId.empId}" selected="selected">${varId.empNameC }</option>
                	 			</c:when>
                	 			<c:otherwise>
                	 				<option value="${varId.empId}">${varId.empNameC  }</option>
                	 			</c:otherwise>
                	 		</c:choose>
                	 	</c:forEach>
                	 </select>                 
                </td>
            </tr>
            <tr>
            	<td align="right" class="l-table-edit-td" style="width:10%">课程名称:</td>
            	<td align="left" class="l-table-edit-td" style="width:40%">
					<select style="width: 180px" name="userid" id="userid" ltype="select" >
                	 	<c:forEach items="${courses}" var="course">
                	 		<c:choose>
                	 			<c:when test="${command.courseid eq  course.id}">
                	 				<option value="${course.id}" selected="selected">${course.title }</option>
                	 			</c:when>
                	 			<c:otherwise>
                	 				<option value="${course.id}">${course.title  }</option>
                	 			</c:otherwise>
                	 		</c:choose>
                	 	</c:forEach>
                	 </select>                 
                </td>
                
                <td align="right" class="l-table-edit-td" style="width:10%">基本课表:</td>
            	<td align="left" class="l-table-edit-td" style="width:40%">
					<select style="width: 180px" name="userid" id="userid" ltype="select" >
                	 	<c:forEach items="${btables}" var="btable">
                	 		<c:choose>
                	 			<c:when test="${command.bid eq  btable.id}">
                	 				<option value="${btable.id}" selected="selected">${btable.title }</option>
                	 			</c:when>
                	 			<c:otherwise>
                	 				<option value="${btable.id}">${btable.title}</option>
                	 			</c:otherwise>
                	 		</c:choose>
                	 	</c:forEach>
                	 </select>                 
                </td>
            </tr>
            <tr>
            	<td align="right" class="l-table-edit-td" style="width:10%"> 启用:</td>
            	<td align="left" class="l-table-edit-td" style="width:40%">
            		<c:choose>
                		<c:when test="${command.isEnable eq 'F' }">
                			<input id="isEnable" type="checkbox" name="isEnable" value="F" onchange="changeTnf(this)"/> 
                		</c:when>
                		<c:otherwise>
                			<input id="isEnable" type="checkbox" name="isEnable" value="T" checked="checked"  onchange="changeTnf(this)"/> 
                		</c:otherwise>
                	</c:choose>
            	</td>
            </tr>
            <tr>
            	<td align="right" class="l-table-edit-td" style="width:10%"> 课表说明:</td>
            	<td align="left" class="l-table-edit-td" style="width:85%" colspan="3" > 
					<input name="desc" type="text" id="desc" value="${command.desc}" style="width:300px"   validate="{required:true}"/>
				</td>
            </tr>
            <c:if test="${viewType ne 'add' }">
	           <tr>
	                <td align="right" class="l-table-edit-td" valign="top">建档人:</td>
	                <td align="left" class="l-table-edit-td" >${command.userCre }</td>
	                
	                <td align="right" class="l-table-edit-td" valign="top">修改人:</td>
	                <td align="left" class="l-table-edit-td" >${command.userUpd }</td>
	           </tr>
	           <tr>
	                <td align="right" class="l-table-edit-td" valign="top">建档日期:</td>
	                <td align="left" class="l-table-edit-td">${command.dateCre }</td>
	                
	                <td align="right" class="l-table-edit-td" valign="top">修改日期:</td>
	                <td align="left" class="l-table-edit-td" >${command.dateUpd }</td>
	           </tr>
           </c:if>
        </table>
    </form>
</body>
</html>